package com.gongzhiyun.springboot3test.listener;

import com.gongzhiyun.springboot3test.utils.IpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AppListener implements ApplicationListener<ApplicationReadyEvent> {
    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("应用程序启动===========");
        Integer port=event.getApplicationContext().getEnvironment().getProperty("server.port",Integer.class);
        String ip= IpUtils.getLocalIp();
        log.info("http://{}:{}",ip,port);
        log.info("http://{}:{}","127.0.0.1",port);

    }
}
